﻿using IBLL;
using IDAL;
using Model;

namespace BLL
{
    public class RoomNumBLL : IRoomNunBLL
    {
        public RoomNumBLL(IBase<RoomNum> db)
        {
            Db = db;
        }

        public IBase<RoomNum> Db { get; }
        /// <summary>
        /// 查全部信息
        /// </summary>
        /// <returns>返回</returns>
        public IQueryable<RoomNum> GetAll()
        {
            return Db.GetAll();
        }
        /// <summary>
        /// 根据编号查一条数据
        /// </summary>
        /// <param name="id">编号</param>
        /// <returns>返回</returns>
        public RoomNum GetValue(int id)
        {
            return Db.GetValue(id);
        }

        /// <summary>
        /// 批量修改状态
        /// </summary>
        /// <param name="id">编号</param>
        /// <param name="state">状态</param>
        /// <returns>返回</returns>
        public Task<int> UpdateAllState(int id,bool state)
        {
            var m=Db.GetValue(id);
            m.IsActive = state;
            return Db.UpdateAsync(m);
        }

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="t">参数</param>
        /// <returns>返回</returns>
        public Task<int> UpdateAsync(RoomNum t)
        {
            return Db.UpdateAsync(t);
        }
        
    }
}
